/*
* ============================================================================
*  Name     : CMyPicture from MyPicture.h
*  Part of  : RichTextEditor
*  Created  : 05/08/2006 by Forum Nokia 
*  Version  : 2.0
*  Copyright: Forum Nokia
* ============================================================================
*/

#ifndef CMYPICTURE_H
#define CMYPICTURE_H

// INCLUDES
#include <gdi.h>
#include <BADESCA.H>
#include <eikenv.h>

// FORWARD DECLARATIONS
class TSize;
class CFbsBitmap;
class MyRichEditor;
// CLASS DECLARATION
/**
*  CMyPicture the class which draw the image.
*/
class CMyPicture :public CPicture
    {
    public:  // Constructors and NO destructor (bitmap not owned)
        
        /**
        * C++ default constructor.
		* @param aSize Size of the picture in twips.
		* @param aBitmap Bitmap
        */
        CMyPicture( TSize aSize, CFbsBitmap& aBitmap, CFbsBitmap& aMaskBitmap );

	public: // From CPicture

		/**
		* Prohibit linebreaks.
		*/
		TBool LineBreakPossible( TUint aClass,
								 TBool aBeforePicture,
								 TBool aHaveSpaces ) const;
		/**
        * Draw the picture
        */
		 void Draw( CGraphicsContext& aGc,
						   const TPoint& aTopLeft,
						   const TRect& aClipRect,
						   MGraphicsDeviceMap* aMap ) const;
		/**
        * There's no need for it in this , but must be implemented.
        */
		 void ExternalizeL( RWriteStream& aStream ) const;
		
        /**
        * Sets the picture's size in twips.
		* @param aSize Size.
        */
		 void SetOriginalSizeInTwips( TSize aSize );

        /**
        * Returns the picture's size in twips.
		* @param aSize Size.
        */
		 void GetOriginalSizeInTwips( TSize& aSize ) const;

	protected:	// Data

		TSize iSizeInTwips; // Size of the bitmap data
		CFbsBitmap* iBitmap; // reference to the Bitmap data
		CFbsBitmap* iMaskBitmap; // reference to the Bitmap data		
public:
	int docpos;
};

//control for preview the image
class CMyPreview :public CMyPicture
{
friend class MyRichEditor;		
public:	
    CMyPreview( TSize aSize, CFbsBitmap& aBitmap, CFbsBitmap& aMaskBitmap );
	void Draw( CGraphicsContext& aGc, const TPoint& aTopLeft, const TRect& aClipRect, MGraphicsDeviceMap* aMap ) const;
	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);	 
public:
	bool iSelected;
protected:
	MyRichEditor* iOwner;	
private:
	int iItemSelected;	
	int iItemsInLine; //be 4
	int iScrollItems;//向左卷过去的item个数
};

class CPicMemo :public CPicture
{
public:  // Constructors and NO destructor (bitmap not owned)
         CPicMemo( TSize aSize, CFbsBitmap& aBitmap );
		~CPicMemo();
public: // From CPicture
		TBool LineBreakPossible( TUint aClass,
								 TBool aBeforePicture,
								 TBool aHaveSpaces ) const;

		void Draw( CGraphicsContext& aGc,
						   const TPoint& aTopLeft,
						   const TRect& aClipRect,
						   MGraphicsDeviceMap* aMap ) const;
		 void ExternalizeL( RWriteStream& aStream ) const;
		 void GetOriginalSizeInTwips( TSize& aSize ) const;
		 void SetOriginalSizeInTwips( TSize aSize );
		 void SetText(const TDesC& aText);		 
protected:	// Data
		TSize iSizeInTwips; // Size of the bitmap data
		CFbsBitmap* iBitmap; // reference to the Bitmap data
public:
	int docpos;
	bool iSelected;
	HBufC* iText;
};

typedef struct ICONDATA
{
	TBuf<256> src;
	CFbsBitmap* bitmap;
	CFbsBitmap* maskbitmap;
};	

#endif
            
